commonlibsse_ng\re\c/
CompactingStore.rs

1use core::ffi::c_void;
2
3use crate::re::BSAtomic::BSNonReentrantSpinLock;
4use crate::re::IMemoryStoreBase::{IMemoryStoreBase, MemoryStats};
5use crate::re::offsets_rtti::RTTI_CompactingStore__Store;
6use crate::re::offsets_vtable::VTABLE_CompactingStore__Store;
7use crate::rel::ResolvableAddress as _;
8use crate::rel::id::VariantID;
9
10/// Dummy
11#[repr(C)]
12pub struct BlockHeader;
13/// Dummy
14#[repr(C)]
15pub struct FreeBlock;
16/// Dummy
17#[repr(C)]
18pub struct StoreBlock;
19
20#[repr(C)]
21pub struct Store {
22    /// C++ Base class `IMemoryStoreBase`.
23    pub __base: IMemoryStoreBase,
24
25    // Members
26    pub lock: BSNonReentrantSpinLock,
27    pub allocBase: *mut c_void,
28    pub allocEndMin: *mut c_void,
29    pub allocEnd: *mut c_void,
30    pub storeEnd: *mut c_void,
31    pub lastBlock: *mut BlockHeader,
32    pub smallFree: [*mut FreeBlock; 66],
33    pub currentFree: *mut FreeBlock,
34    pub nextMerge: *mut FreeBlock,
35    pub storeBlockMin: *mut StoreBlock,
36    pub nextStoreBlock: *mut StoreBlock,
37    pub freeStoreBlockList: *mut StoreBlock,
38    pub currentThread: u32,
39    pub allocated: usize,
40    pub numAllocatedBlocks: u32,
41    pub free: usize,
42    pub numFreeBlocks: u32,
43    pub compacted: u32,
44    pub batchDeallocateTlsSlot: u32,
45}
46const _: () = {
47    use std::mem;
48    assert!(mem::size_of::<Store>() == 0x2A0);
49    assert!(mem::align_of::<Store>() == mem::align_of::<IMemoryStoreBase>());
50};
51
52impl Store {
53    /// Runtime Type Information (RTTI) identifier.
54    pub const RTTI: VariantID = RTTI_CompactingStore__Store;
55    /// Virtual table identifier.
56    pub const VTABLE: [VariantID; 1] = VTABLE_CompactingStore__Store;
57
58    #[inline]
59    pub fn vtable(&self) -> Option<&'static StoreVtbl> {
60        Some(unsafe { Self::VTABLE[0].address().ok()?.cast().as_ref() })
61    }
62}
63
64/// Virtual table for `Store`.
65#[repr(C)]
66pub struct StoreVtbl {
67    /// C++ `virtual ~Store`
68    pub CxxDrop: unsafe extern "C" fn(this: *mut Store),
69    pub Size: unsafe extern "C" fn(this: *const Store, mem: *const u8) -> usize,
70    pub GetMemoryStats: unsafe extern "C" fn(this: *mut Store, stats: *mut MemoryStats),
71    pub ContainsBlockImpl: unsafe extern "C" fn(this: *const Store, block: *const u8) -> bool,
72}